package dhm.com.dhmshop.adapter.mine;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;
import java.util.List;

import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.entity.SeecuiBean;
import dhm.com.dhmshop.view.mine.myshop.ShoporderdActivity;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class SeeCuiAdapter extends RecyclerView.Adapter<SeeCuiAdapter.ViewHolder> {

    private List<SeecuiBean.DataBean> shopList;

    private Context context;


    public SeeCuiAdapter( Context context) {
        shopList = new ArrayList<>();
        this.context = context;
    }

    public void showImage(List<SeecuiBean.DataBean> shopList) {
        this.shopList = shopList;
        notifyDataSetChanged();
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view= LayoutInflater.from(context).inflate(R.layout.item_cui, viewGroup,false);
        viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
        viewHolder.image.setImageURI(Constant.PATH+"/" + shopList.get(i).getHeadsmall());
        viewHolder.image_goods.setImageURI(Constant.PATH +"/"+ shopList.get(i).getHeadsmall());
        viewHolder.shop_name.setText(shopList.get(i).getUser_nickname());
        viewHolder.name.setText(shopList.get(i).getUser_nickname());
        viewHolder.orderId.setText("订单号:"+shopList.get(i).getOrder_sn());
        viewHolder.param.setText(shopList.get(i).getUser_nickname());
        viewHolder.time.setText("下单时间:"+shopList.get(i).getAdd_time());
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(context, ShoporderdActivity.class);
                intent.putExtra("order_id",shopList.get(i).getOrder_id()+"");
                intent.putExtra("uid",shopList.get(i).getUid()+"");
                context.startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return shopList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public SimpleDraweeView image;
        public SimpleDraweeView image_goods;
        public TextView shop_name;
        public TextView name;
        public TextView param;
        public TextView orderId;
        public TextView time;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            image = itemView.findViewById(R.id.image);
            image_goods = itemView.findViewById(R.id.image_goods);
            shop_name = itemView.findViewById(R.id.shop_name);
            name = itemView.findViewById(R.id.name);
            param = itemView.findViewById(R.id.param);
            orderId = itemView.findViewById(R.id.orderId);
            time = itemView.findViewById(R.id.time);
        }
    }

    private OnClick onClick;

    public void setdeleteClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public interface OnClick {
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;

    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }

    public interface OnIntentClick {
        void item();
    }


}

